package com.youdianda.controller;


import com.youdianda.dto.YddArticleListDTO;
import com.youdianda.entity.YddArticle;
import com.youdianda.result.Result;
import com.youdianda.service.IYddArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sdy
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ydd_article")
public class YddArticleController {
    @Autowired
    private IYddArticleService iYddArticleService;

    /**
     * 文章详情
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result details(Integer id){
        return  iYddArticleService.details(id);
    }

    /**
     * 文章列表-分页
     */
    @GetMapping("/list")
    public Result getYddTagIPage(YddArticleListDTO yddArticleDto){
        return iYddArticleService.getYddTagIPage(yddArticleDto);
    }


    /**
     * 文章删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result deleteById(Integer id){

        return iYddArticleService.deleteById(id);
    }

    /**
     * 文章修改
     * @param yddArticle
     * @return
     */
    @PostMapping("/update")
    public Result upDate(@RequestBody YddArticle yddArticle){

        return iYddArticleService.upDate(yddArticle);
    }

    /**
     * 文章添加
     * @param yddArticle
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody YddArticle yddArticle){
        return  iYddArticleService.add(yddArticle);
    }


}
